<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/3/12
 * Time: 下午2:10
 */

namespace App\Busi\Traits;


use App\Models\Dist;

Trait DistTrait
{
    public function getDistNamePid($parent_id){
        if($parent_id == -1){
            $dist_name = "中国";
            return $dist_name;
        }
        $where = [
            ['id','=',$parent_id]
        ];
        $fields = ['dist_name'];
        $data = Dist::where($where)->select($fields)->first();
        if(!$data){
            $dist_name = "中国";
            return $dist_name;
        }
        $dist_name = $data['dist_name'];


        return $dist_name;
    }
    public function getDistByPid($parent_id){
        $where = [
            ['id','=',$parent_id]
        ];
        $fields = ['id','dist_name'];
        $data = Dist::where($where)->select($fields)->first();
        return $data;
    }

}